﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UI.Desktop
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MdiChildren.Length > 0)
            {
                if (CommonControls.AskBox(Text, "¿Desea cerrar los módulos abiertos y salir del sistema?") == DialogResult.Yes) Dispose();
                else e.Cancel = true;
            }
            else Dispose();
        }

        private void ShowForm(Type form_type)
        {
            foreach (Form f in MdiChildren) f.Dispose();
            Form form = (Form)Activator.CreateInstance(form_type);
            form.MdiParent = this;
            form.WindowState = FormWindowState.Maximized;
            form.Show();
        }

        private void mnSistema_Salir_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void mnModulos_Carreras_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Carreras.ABM));
        }

        private void mnModulos_Planes_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Planes.ABM));
        }

        private void mnModulos_Comisiones_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Comisiones.ABM));
        }

        private void mnModulos_Materias_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Materias.ABM));
        }

        private void mnModulos_Alumnos_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Alumnos.ABM));
        }

        private void mnModulos_Docentes_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Docentes.ABM));
        }

        private void mnModulos_Administradores_Click(object sender, EventArgs e)
        {
            ShowForm(typeof(Administradores.ABM));
        }
    }
}
